﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace FileTest1.JavaFileOperator
{
    class JavaMethod
    {
        public string id;
        public string accessModifier;
        public string returnType;
        public string methodName;
        public List<JavaParameter> parameterList;
        public string description;
        public List<JavaCodeLine> codes;
//         void go()
//         {
//             
//             JavaParameter i = this.parameterList[1];
//         }
        public JavaMethod(string id,
            string accessModifier,
            string returnType,
            string methodName,
            List<JavaParameter> parameterList)
        {
            this.id = id;
            this.accessModifier = accessModifier;
            this.returnType = returnType;
            this.methodName = methodName;
            this.parameterList = parameterList;
            JavaCodeLine methodBegin = new JavaCodeLine(CodeType.MethodBegin);
            methodBegin.code = this.accessModifier + " " + this.returnType + " " + this.methodName + "(";
            if (parameterList!=null)
            {
                for (int i = 0; i < parameterList.Count;i++ )
                {
                    JavaParameter p = parameterList[i];
                    methodBegin.code +=p.code;
                    if (i>0)
                    {
                        methodBegin.code += ", " + p.code;
                    }
                }

            }
            methodBegin.code += ") {";
            JavaCodeLine methodEnd = new JavaCodeLine(CodeType.MethodEnd);
            methodEnd.code = "}";

            this.codes = new List<JavaCodeLine>();
            codes.Add(methodBegin);
            codes.Add(methodEnd);
                
        }


    }
}
